/*
	定义自定义的字段类型校验
 */
(function(mini) {
	'use strict';

	mini.VTypes['rsEnglishErrorText'] = '只允许输入英文字母';
	mini.VTypes['rsEnglish'] = function(v) {
		var re = /^[a-zA-Z]*$/;
		if (re.test(v)) return true;
		return false;
	};

	mini.VTypes['rsEnglishUpperErrorText'] = '只允许输入大写英文字母';
	mini.VTypes['rsEnglishUpper'] = function(v) {
		var re = /^[A-Z]*$/;
		if (re.test(v)) return true;
		return false;
	};

	mini.VTypes['rsEnglishUErrorText'] = '只允许输入英文字母或下划线';
	mini.VTypes['rsEnglishU'] = function(v) {
		var re = /^[a-zA-Z\_]*$/;
		if (re.test(v)) return true;
		return false;
	};

	mini.VTypes['rsEnglishNumberUErrorText'] = '只允许输入英文字母、数字或下划线';
	mini.VTypes['rsEnglishNumberU'] = function(v) {
		var re = /^[0-9a-zA-Z\_]*$/;
		if (re.test(v)) return true;
		return false;
	};

	mini.VTypes['rsChineseErrorText'] = '只允许输入中文';
	mini.VTypes['rsChinese'] = function(v) {
		var re = /^[\u4e00-\u9fa5]*$/;
		if (re.test(v)) return true;
		return false;
	};

	mini.VTypes['rsBusinessCodeErrorText'] = '业务编码只允许输入英文字母、数字或下划线';
	mini.VTypes['rsBusinessCode'] = function(v) {
		var re = /^[0-9a-zA-Z\#\-\_]*$/;
		if (re.test(v)) return true;
		return false;
	};

	mini.VTypes['rsTelNumberErrorText'] = '电话号码只允许输入数字、加号或横杠';
	mini.VTypes['rsTelNumber'] = function(v) {
		var re = /^[0-9\+\-]*$/;
		if (re.test(v)) return true;
		return false;
	};
	
	mini.VTypes["rsJldwCodeErrorText"] = "只允许输入中文、英文字母、数字或下划线";
	mini.VTypes["rsJldwCode"] = function(v) {
		var re = /^[0-9a-zA-Z\u4e00-\u9fa5\_]*$/;
		if (re.test(v)) return true;
		return false;
	}
	
	mini.VTypes["rsZlhCodeErrorText"] = "只允许输入中文、英文字母、数字、横杆或下划线";
	mini.VTypes["rsZlhCode"] = function(v) {
		var re = /^[0-9A-Z\u4e00-\u9fa5\_\-]*$/;
		if (re.test(v)) return true;
		return false;
	}
})(mini);


var rs = (function(rs) {
	'use strict';

	rs.validateMonth = function(month) {
		if (isNaN(month) || parseInt(month) !== month || month <= 0 || month > 12) {
			return false;
		}
		return true;
	};

	rs.validateDayOfMonth = function(day) {
		if (isNaN(day) || parseInt(day) !== day || day <= 0 || day > 31) {
			return false;
		}
		return true;
	};

	rs.validateHour = function(hour) {
		if (isNaN(hour) || parseInt(hour) !== hour || hour < 0 || hour >= 24) {
			return false;
		}
		return true;
	};

	rs.validateMinute = function(minute) {
		if (isNaN(minute) || parseInt(minute) !== minute || minute < 0 || minute >= 60) {
			return false;
		}
		return true;
	};

	rs.validateSecond = function(second) {
		if (isNaN(second) || parseInt(second) !== second || second < 0 || second >= 60) {
			return false;
		}
		return true;
	};

	return rs;
})(window.rs || {});